from datetime import timedelta
from typing import Annotated
import random
import string
from fastapi import APIRouter, Depends, status, HTTPException
from fastapi.security import OAuth2PasswordRequestForm
from app.api.deps import CurrentUser, SessionDep
from app.core import security
from app.core.config import settings
from app.core.security import get_password_hash
from app.models import  Token, LoginForm,TokenResponse,UserPublicResponse,PhoneRegisterRequest,PhoneRegisterResponse,PhoneVerificationCodeRequest,PhoneVerificationCodeResponse,UserAuth,CaptchaResponse
from app.core.security import verify_password
from app import services
from app import  models

router = APIRouter()
# 按时间查询信号值的比赛
@router.post("/football/getMatches", response_model=models.MatchesResultResponse)
async def getMatches(session: SessionDep,current_user: CurrentUser,req:models.SearchCondition):
    
    return await services.FootballService(current_user=current_user,db=session).Search_matches_by_time(req)        

 
@router.post("/football/Signal")
async def getSignal(
    session: SessionDep, current_user: CurrentUser,req:models.SignalCondition
) -> models.SignalResultResponse:
    """
    通过比赛id和公司id获得信号值
    """
    return await services.FootballService(current_user=current_user,db=session).get_signal(req)


@router.get("/football/getEventList", response_model=models.EventListResultResponse)
async def getEventList(session: SessionDep, current_user: CurrentUser):
    """
    获取赛事列表，按比赛数量降序排列
    """
    return await services.FootballService(current_user=current_user, db=session).get_event_list()


@router.post("/football/getSimilarMatches", response_model=models.SimilarMatchesResultResponse)
async def getSimilarMatches(session: SessionDep, current_user: CurrentUser, req: models.SimilarMatchesCondition):
    """
    根据赔率和信号范围获取相似比赛
    """
    return await services.FootballService(current_user=current_user, db=session).get_similar_matches(req)
